import os
import random
import time
import math

def fuzzCallback(func,factor):
	'''
	dumbest.fuzzer.ever.
	'''
	while 1:
		# choose file to mutate
		file_list = os.listdir("examples/")
		list_length = len(file_list)
		file_name = file_list[random.randint(0,list_length-1)]
		file_name = "examples/" + file_name
		print "[*] File chosen: %s" % file_name
		
		# get file input
		edk = open(file_name,"r").read()
		edk_len = len(edk)
		
		# main mutation
		random.seed(time.time())
		num_of_mutations = random.randrange(math.ceil(float(edk_len)/factor))+1
		for i in range(num_of_mutations):
			kar = random.randrange(256)
			kar_num = random.randrange(edk_len)
			edk2 = edk[0:kar_num-1]
			edk2 = edk2 + "%c" % (kar)
			edk2 = edk2 + edk[kar_num:edk_len]
			edk = edk2
		func(edk)
